﻿using AdinZ.Web.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
/**
* @Author: AdinZ
* @Q  Q : 1454269
* @Email:adinz@adinz.com
* @Created: 2014/4/6 21:02:17
* */
namespace Web
{
    public partial class download : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //download.aspx?id=1134
            //download.aspx?id=1134&chapter=120443
            int bookID=0;
            int chapterID=0;
            string book = Request["id"];
            string chapter = Request["chapter"];
            if (!string.IsNullOrEmpty(book))
                bookID = int.Parse(book);
            if (!string.IsNullOrEmpty(chapter))
                chapterID = int.Parse(chapter);
            if (chapterID > 0)
            {
                AdinZ.Common.NetServer.Get(siteConfig.SiteHost + "/plug/number.ashx?action=downloads&id=" + bookID);
                Novel.Sys.BLL.novel_chapter bll = new Novel.Sys.BLL.novel_chapter();
                Novel.Sys.Model.novel_chapter model = new Novel.Sys.Model.novel_chapter();
                model = bll.GetModel(chapterID);
                Response.Clear();
                Response.ContentType = "application/octet-stream";
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", siteConfig.FileHost + model.Articlepath);
                Response.End();
                //按章下载
            }
            else if (bookID > 0)
            {
                //下载全本
                Response.Write("<script type=\"text/javascript\">alert('暂不支持下载全本');top.location.href='/'</script>");
            }
        }
    }
}